from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _

from user.form import BBSUserCreationForm
from user.models import BBSUser, MessageModel


# Register your models here.
@admin.register(BBSUser)
class BBSUserAdmin(UserAdmin):
    fieldsets = (
        (None, {'fields': ('email', 'password',)}),
        (_('Personal info'), {'fields': ('nickname', 'desc', 'avatar', 'sex', 'city')}),
        ('账户信息', {'fields': ('renzheng', 'vip', 'coin')}),
        (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser',
                                       'groups', 'user_permissions')}),
        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
    )
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('email', 'nickname', 'password1', 'password2'),
        }),
    )
    ordering = ('email',)
    readonly_fields = ('date_joined',)
    list_display = ('email', 'nickname', 'renzheng', 'vip', 'coin')
    add_form = BBSUserCreationForm


@admin.register(MessageModel)
class MessageAdmin(admin.ModelAdmin):
    list_display = ('sender', 'target', 'content', 'read')
    list_display_links = ('content',)
